package com.wangsd.web.mqpay.controller;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.wangsd.common.basicbean.MyController;
import com.wangsd.common.basicbean.Result;
import com.wangsd.web.mqpay.entity.CustomerFlow;
import com.wangsd.web.mqpay.service.CustomerFlowService;
import com.wangsd.web.sys.entity.SysUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "客户流水管理")
@RestController
@RequestMapping("/mqpay/customerFlow")
@Slf4j
public class CustomerFlowController extends MyController {
    @Resource
    private CustomerFlowService service;

    @ApiOperation(value = "分页查询列表")
    @PostMapping("/selectPage")
    public Object selectPage(@ApiParam(value = "当前第几页", required = true) @RequestParam("pageNum") Integer pageNum,
                             @ApiParam(value = "每页结果集大小", required = true) @RequestParam("pageSize") Integer pageSize,
                             CustomerFlow queryObj) {
        log.debug("分页查询列表-controller");
        SysUser loginUser = getUserInfo();
        Page page = PageHelper.startPage(pageNum, pageSize);
        List<CustomerFlow> list = service.selectPage(queryObj, loginUser.getCode());
        return Result.success(getPageInfo(page, list));
    }

    @ApiOperation(value = "删除客户客户流水")
    @GetMapping("/{id}/delete")
    public Result delete(@ApiParam(value = "客户(商圈)id", required = true) @PathVariable Long id) {
        log.debug("删除客户客户流水-controller");
        service.delete(id);
        return Result.success();
    }

    @ApiOperation(value = "提现完成")
    @GetMapping("/{id}/complete")
    public Result complete(@ApiParam(value = "客户流水id", required = true) @PathVariable Long id) {
        log.debug("提现完成-controller");
       service.complete(id);
        return Result.success();
    }
}
